package com.xxx.modules.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xxx.modules.mapper.DrugMapper;
import com.xxx.modules.entity.Drug;
import com.xxx.modules.service.DrugService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import java.util.List;
import java.util.Arrays;
import com.xxx.modules.utils.TimeUtil;

/**
 * drug
 *
 * @author 北易航
 * @since 1.0.0 2023-02-05
 */
@Service
public class DrugServiceImpl extends ServiceImpl<DrugMapper, Drug> implements DrugService {

    @Autowired
    private DrugMapper drugMapper;


    @Override
    public PageInfo<Drug> selectDrugInfo(Drug drug, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        QueryWrapper<Drug> wrapper = new QueryWrapper<>();
        List<Drug> data = drugMapper.selectListInfo(drug);
        return new PageInfo<>(data);
    }

    @Override
    public void saveDrugInfo(Drug drug) {
        drugMapper.insert(drug);
    }

    @Override
    public void updateDrugInfo(Drug drug) {
        drugMapper.updateById(drug);
    }

    @Override
    public void delDrugInfo(Integer id) {
        drugMapper.deleteById(id);
    }

    @Override
    public void delBatchDrugInfo(String idList) {
        List<String> list = Arrays.asList(idList.split(","));
        drugMapper.deleteBatchIds(list);
    }


}